﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace App
{
    public partial class EditMessage : System.Web.UI.Page
    {
        int MessageID, ThreadID;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Common.GetLoggedUser(this.Page) == null)
            {
                Response.Redirect("Login.aspx");
                return;
            }
            MessageID = int.Parse(Server.HtmlEncode(Request.Cookies["MessageID"].Value));
            ThreadID = int.Parse(Server.HtmlEncode(Request.Cookies["MessageList"].Value));


        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            TextBoxEditMessage.Text = MidApp.ManageMessage.GetMessage(ThreadID, MessageID).Report;
        }

        protected void ButtonEditMessage_Click(object sender, EventArgs e)
        {
            AppLib.Message message = MidApp.ManageMessage.GetMessage(ThreadID, MessageID);
            message.Report = TextBoxEditMessage.Text;
            MidApp.ManageMessage.EditMessage(message);
            //lblInfo.Text = "Zpráva byla uložena";
            Response.Redirect("MessageList.aspx");
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Response.Redirect("MessageList.aspx");
        }

    }
}